//
//  YHIMUIKitDefine.h
//  YHChat
//
//  Created by 银河 on 2019/2/18.
//  Copyright © 2019 yinhe. All rights reserved.
//

#ifndef YHIMUIKitDefine_h
#define YHIMUIKitDefine_h
#import <UIKit/UIKit.h>

#define YHIMUIKitError(__msg__,__code__)   [NSError errorWithDomain:@"com.error.yinhe.chat" code:(__code__) userInfo:@{NSLocalizedDescriptionKey:__msg__}]


#ifdef DEBUG
    #define YHIMUIKitLog(format, ...)   printf("✌️✌️✌️✌️✌️✌️[YHIMUIKit] [%s] [%d] %s\n" ,[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:format, ##__VA_ARGS__] UTF8String])
#else
    #define YHIMUIKitLog(...)
#endif

#define YHIMUIKit_RandomColor            [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]
#define YHIMUIKit_RGB(R,G,B)             [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1]
#define YHIMUIKit_RGBA(R,G,B,A)          [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
#define YHIMUIKit_HexColor(hex)          [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0 green:((float)((hex & 0xFF00) >> 8))/255.0 blue:((float)(hex & 0xFF))/255.0 alpha:1.0]

#define YHIMUIKit_ScreenWidth            [UIScreen mainScreen].bounds.size.width
#define YHIMUIKit_ScreenHeight           [UIScreen mainScreen].bounds.size.height

#define YHIMUIKit_DeviceOrientation    [UIApplication sharedApplication].statusBarOrientation


#define YHIMUIKit_IS_IPHONE_X \
({ \
BOOL isIphoneX = NO; \
if (YHIMUIKit_DeviceOrientation == UIInterfaceOrientationPortrait || \
    YHIMUIKit_DeviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { \
    if ((YHIMUIKit_ScreenWidth == 375.f && YHIMUIKit_ScreenHeight == 812.f) || (YHIMUIKit_ScreenWidth == 414.f && YHIMUIKit_ScreenHeight == 896.f)) { \
        isIphoneX = YES; \
    } \
} else { \
    if ((YHIMUIKit_ScreenWidth == 812.f && YHIMUIKit_ScreenHeight == 375.f) || (YHIMUIKit_ScreenWidth == 896.f && YHIMUIKit_ScreenHeight == 414.f)) { \
        isIphoneX = YES; \
    } \
} \
(isIphoneX); \
})


#define YHUIKit_Bottom_Height \
({ \
CGFloat bottomHeight = 0.0; \
if (YHIMUIKit_IS_IPHONE_X) { \
    if (YHIMUIKit_DeviceOrientation == UIDeviceOrientationPortrait || \
        YHIMUIKit_DeviceOrientation == UIDeviceOrientationPortraitUpsideDown || \
        YHIMUIKit_DeviceOrientation == UIDeviceOrientationFaceUp || \
        YHIMUIKit_DeviceOrientation == UIDeviceOrientationFaceDown) { \
        bottomHeight = 34.f; \
    } else { \
    bottomHeight = 21.f; \
    } \
} \
(bottomHeight); \
})


#define YHIMUIKit_Resource(name) [[[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"YHIMUIKitResource" ofType:@"bundle"]] resourcePath] stringByAppendingPathComponent:name]



// 头像尺寸
#define YHIMUIKit_HeadSize                CGSizeMake(45.0, 45.0)
// 状态Node的size
#define YHIMUIKit_StateSize               CGSizeMake(30.0, 30.0)
// cell偏移量
#define YHIMUIKit_CellInset               UIEdgeInsetsMake(10.0, 8.0, 10.0, 8.0)
// 气泡内的消息偏移量
#define YHIMUIKit_BubbleInset             UIEdgeInsetsMake(10.0, 8.0, 10.0, 8.0)



// 每次获取消息的数量
#define YHIMUIKit_MsgCountPerRequest      20



/**
 * 会话类型
 */
typedef NS_ENUM(NSUInteger, YHIMUIKitConvType) {
    YHIMUIKitConvType_C2C,           // 单聊
    YHIMUIKitConvType_Group,         // 群聊
    YHIMUIKitConvType_System,        // 系统消息
};




typedef NS_ENUM(NSUInteger, YHIMUIKitMsgStatus) {
    YHIMUIKitMsgStatus_Ready,
    YHIMUIKitMsgStatus_Sending,
    YHIMUIKitMsgStatus_Success,
    YHIMUIKitMsgStatus_Fail,
};


#endif /* YHIMUIKitDefine_h */
